<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>XML Parsing php</title>
<style>
#score-catagory-wrapper{
	 width : 600px;
}

#score-catagory-wrapper .catagory{
	 margin-top : 20px;
}
#score-catagory-wrapper .catagory>.info{
	background-color:#FC3;
	border-bottom:solid #F00 1px;
}

#score-catagory-wrapper .match>.info{
	background-color:olive;
	border-bottom:solid #F00 1px;
}
.left{
	float: left;
}

.right{
	float:right;
}

.w60{
	width:60%;
}
.w40{
	width:40%;
}

.w100{
	width:100%;
}

.h20{
	height:20px;
}

.clear {
	clear: both;
}
</style>
</head>
<body>

<?php
$docRoot = $_SERVER['DOCUMENT_ROOT'].'/'.strtok($_SERVER['PHP_SELF'], '/');
include_once $docRoot.'/application/service/feed/util/HtmlUtil.php';

$xmlObject = simplexml_load_file("feeds/italy.xml");

$outputHTML = "<div id='score-catagory-wrapper'>";

foreach ($xmlObject->children() as $catagory) {
        $catagoryAttr = $catagory->attributes();   // returns an array
		$outputHTML .= "<div class='catagory'>";
		//push catagory attribute
		$outputHTML .= "<div class='info w100 h20'>";
			$outputHTML .= HtmlUtil::createHtmlDiv("name left w60",$catagoryAttr["name"]);
			$outputHTML .= HtmlUtil::createHtmlDiv("country right w40",$catagoryAttr["country"]);	
		$outputHTML .= "</div>";
         		
		$outputHTML .= HtmlUtil::createHtmlDiv("clear","");
		
		 //get all match node
		 foreach ($catagory->children() as $match) {
			 $matchAttr = $match->attributes();
			 
			 $outputHTML .= "<div class='match'>";
			 $outputHTML .= "<div class='info'>";
			   $outputHTML .= "<div class='date'>".$matchAttr['date']."</div>";
			   $outputHTML .= "<div class='time'>".$matchAttr['time']."</div>";
			   $outputHTML .= "<div class='status'>".$matchAttr['status']."</div>";
			  $outputHTML .= "</div>";
			   
			   $matchInfo = $match->children();
			   
			   $localteamAttr =  $matchInfo[0]->attributes();
			   $outputHTML .= "<div class='localteamName'><a href='#'>".$localteamAttr['name']."</a></div>";
			   
			   $awayteamAttr =  $matchInfo[1]->attributes();
			   $outputHTML .= "<div class='awayteamName'><a href='#'>".$awayteamAttr['name']."</a></div>";
			   
			   //check of events if totalscore="" donot display events
			   if ($localteamAttr['totalscore'] != "")
			   {
			   	  foreach ($matchInfo[2]->children() as $events){
			   	  	 $eventAttr = $events->attributes();
			   	  	 if ($eventAttr['score'] != ""){
			   	  	 $outputHTML.= "<div class='score'>".$events->getName()." :: ".$eventAttr['score']."</div>";
			   	  	 }
			   	  	 foreach($events->children() as $scoreDetails){
			   	  	 	$scoreDeatilsAttr = $scoreDetails->attributes();
			   	  	 	$outputHTML .= "<div class='score-details'> Player :".$scoreDeatilsAttr['player']."</div>";
			   	  	 }
			   	  	
			   	  }
			   }
			 
			   //match div ends
			 $outputHTML .= "</div>";
		 }

		 //Catagory Div ends ehre
		$outputHTML .= '</div>';
}
//Wrapper Div ends here
$outputHTML .= '</div>';
print ($outputHTML);
?>


<?php
		
       // print ("name=".$arr["name"]);     // get the value of this attribute
        //print ("  match=".$node->match);
        //print ("<p><hr>");

?>
</body>
</html>